<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='lb'/></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
    <style>
        .feijin-split {
            border-left: 1px dashed #ccc;
        }
    </style>
</head>
<body>

<div class="layui-fluid">

    <div class="layui-card-body">
        <div class="layui-row layui-col-space30">

            <div class="layui-col-xs2 layui-card" style="width:25%;height:120px;">
                <a class="layadmin-backlog-body">
                    <center>
                        <h4><fmt:message key='dds'/></h4></br>
                        <p><cite style="color:red">${page.totalCount}</cite></p>
                    </center>
                </a>
            </div>

            <div class="layui-col-xs2 layui-card feijin-split" style="width:25%;height:120px;">
                <a class="layadmin-backlog-body">
                    <center>
                        <h4><fmt:message key='cjje'/></h4></br>
                        <p><cite style="color:red"> <fmt:formatNumber value="${payAmount}" type="CURRENCY"/></cite></p>
                    </center>
                </a>
            </div>

            <div class="layui-col-xs2 layui-card feijin-split" style="width:25%;height:120px;">
                <a class="layadmin-backlog-body">
                    <center>
                        <h4><fmt:message key='sjtk'/></h4></br>
                        <p><cite style="color:red"><fmt:formatNumber value="${refundAmount}" type="CURRENCY"/></cite></p>
                    </center>
                </a>
            </div>
        </div>
    </div>


    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">

            <div class="layui-form-item">
                <form name="totalForm" id="totalForm" action="${web_domain}/mall/member/${id}/orders" method="get">

                    <div class="layui-inline">
                        <label class="layui-form-label"><fmt:message key='ddbh'/></label>
                        <div class="layui-input-inline">
                            <input type="text" name="orderNo" placeholder="<fmt:message key='qsrddmc'/>" value="<c:if test='${params.orderNo !=null}'>${params.orderNo}</c:if>" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label"><fmt:message key='zfzt'/></label>
                        <div class="layui-input-inline">
                            <select name="payStatus" lay-verify="required" lay-search="">
                                <option value="0"><fmt:message key='qxz'/></option>
                                <option value="1" <c:if test="${1 eq params.payStatus}">selected="selected" </c:if> ><fmt:message key='yzf'/></option>
                                <option value="2" <c:if test="${2 eq params.payStatus}">selected="selected" </c:if> ><fmt:message key='wzf'/></option>
                            </select>

                        </div>
                    </div>


                    <!-- 需要排序的字段 -->
                    <input type="hidden" class="feijin-orderby" name="orderByCreateTime" id="orderByCreateTimeParams" value="${params.orderByCreateTime}"/>
                    <input type="hidden" class="feijin-orderby" name="orderByPrice" id="orderByPriceParams" value="${params.orderByPrice}"/>
                    <!-- 需要排序的字段 -->

                    <input type="hidden" name="status" value="${params.status}"/>

                    <div class="layui-inline">
                        <button class="layui-btn layui-btn-sm layuiadmin-btn-list" id="search"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i> <fmt:message key='ss'/></button>
                    </div>
                </form>
            </div>
        </div>

    </div>

    <div class="layui-card">
        <div class="layui-field-box layui-form">

            <a href="${web_domain}/mall/order/exports?orderNo=${params.orderNo}&deliveryName=${params.deliveryName}&deliveryMobile=${params.deliveryMobile}&payMethod=${params.payMethod}&payStatus=${params.payStatus}&merchant.id=${(empty params.merchant.id) ? 0 : params.merchant.id}" class="layui-btn layui-btn-sm" id="export"><i class="layui-icon">&#xe601;</i> <fmt:message key='dcdd'/></a>

            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                <ul class="layui-tab-title">
                    <li
                            <c:if test="${params.status eq 0}">class="layui-this"</c:if> >
                        <a href="${web_domain}/mall/member/${id}/orders"
                           <c:if test="${params.status eq 0}">style="color: rgb(0, 150, 136)"</c:if> ><fmt:message key='qb'/></a>
                    </li>
                    <li <c:if test="${params.status eq 1}">class="layui-this"</c:if>>
                        <a href="${web_domain}/mall/member/${id}/orders?status=1" <c:if test="${params.status eq 1}">style="color: rgb(0, 150, 136)"</c:if>><fmt:message key='wfk'/></a>
                    </li>
                    <li <c:if test="${params.status eq 2}">class="layui-this"</c:if>>
                        <a href="${web_domain}/mall/member/${id}/orders?status=2" <c:if test="${params.status eq 2}">style="color: rgb(0, 150, 136)"</c:if>><fmt:message key='gggg'/></a>
                    </li>
                    <li <c:if test="${params.status eq 3}">class="layui-this"</c:if>>
                        <a href="${web_domain}/mall/member/${id}/orders?status=3" <c:if test="${params.status eq 3}">style="color: rgb(0, 150, 136)"</c:if>><fmt:message key='dsh'/></a>
                    </li>
                    <li <c:if test="${params.status eq 4}">class="layui-this"</c:if>>
                        <a href="${web_domain}/mall/member/${id}/orders?status=4" <c:if test="${params.status eq 4}">style="color: rgb(0, 150, 136)"</c:if>><fmt:message key='dpj'/></a>
                    </li>
                    <li <c:if test="${params.status eq 5}">class="layui-this"</c:if>>
                        <a href="${web_domain}/mall/member/${id}/orders?status=5" <c:if test="${params.status eq 5}">style="color: rgb(0, 150, 136)"</c:if>><fmt:message key='ywc'/></a>
                    </li>
                    <li <c:if test="${params.status eq 6}">class="layui-this"</c:if>>
                        <a href="${web_domain}/mall/member/${id}/orders?status=6" <c:if test="${params.status eq 6}">style="color: rgb(0, 150, 136)"</c:if>><fmt:message key='yqx'/></a>
                    </li>
                </ul>
            </div>


            <table class="layui-table" lay-size="sm">
                <thead>
                <th><fmt:message key='xh'/></th>
                <th><fmt:message key='ddbh'/></th>
                <th><fmt:message key='sjxx'/></th>
                <th><fmt:message key='mjxx'/></th>
                <th><fmt:message key='shxx1'/></th>
                <th id="orderByCreateTime">
                    <span><fmt:message key='xdxx'/></span>
                    <span class="layui-table-sort layui-inline" lay-sort="${params.orderByCreateTime}"><i class="layui-edge layui-table-sort-asc" title="<fmt:message key='sx1'/>"></i><i class="layui-edge layui-table-sort-desc" title="<fmt:message key='jx'/>"></i></span>
                </th>
                <th id="orderByPrice">
                    <span><fmt:message key='ddzj'/></span>
                    <span class="layui-table-sort layui-inline" lay-sort="${params.orderByPrice}"><i class="layui-edge layui-table-sort-asc" title="<fmt:message key='sx1'/>"></i><i class="layui-edge layui-table-sort-desc" title="<fmt:message key='jx'/>"></i></span>
                </th>
                <th><fmt:message key='zffs'/></th>
                <th><fmt:message key='zfzt'/></th>
                <th><fmt:message key='ddzt'/></th>
                <th><fmt:message key='cz'/></th>
                </thead>
                <c:forEach items="${page.result}" var="item" varStatus="status">
                    <tr>
                        <td>${status.index + 1 }</td>
                        <td>${item.orderNo }</td>
                        <td>
                            <p><fmt:message key='dp'/>：${item.merchant.shopName }</p>
                            <p><fmt:message key='lxr'/>：${item.merchant.realName }</p>
                            <p><fmt:message key='dh'/>：${item.merchant.mobile }</p>
                        </td>
                        <td>
                            <p><fmt:message key='mc'/>：${item.member.nickname }</p>
                            <p><fmt:message key='sj3'/>：${item.member.mobile }</p>
                        </td>
                        <td>
                            <p><fmt:message key='shr'/>：${item.deliveryName}</p>
                            <p>电话：${item.deliveryMobile}</p>
                            <p>地址：${item.deliveryProvince}${item.deliveryCity}${item.deliveryArea}${item.deliveryAddress}</p>
                        </td>
                        <td><fmt:formatDate value="${item.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                        <td><fmt:formatNumber value="${item.price}" type="CURRENCY"/></td>
                        <td>
                            <c:choose>
                                <c:when test="${item.payMethod eq 1}"><b style="color:green;"><fmt:message key='wx'/></b></c:when>
                                <c:when test="${item.payMethod eq 2}"><b style="color:blue"><fmt:message key='zfb'/></b></c:when>
                                <c:when test="${item.payMethod eq 3}"><b style="color:goldenrod;"><fmt:message key='ye1'/></b></c:when>
                                <c:otherwise>-</c:otherwise>
                            </c:choose>
                        </td>
                        <td>
                            <c:choose>
                                <c:when test="${item.payStatus eq 1}"><b style="color:green;"><fmt:message key='yzf'/></b></c:when>
                                <c:when test="${item.payStatus eq 2}"><b style="color:red;"><fmt:message key='wzf'/></b></c:when>
                                <c:otherwise><b style="color:grey;"><fmt:message key='wzf'/></b></c:otherwise>
                            </c:choose>
                        </td>
                        <td>
                            <c:choose>
                                <c:when test="${item.status eq 1}"><fmt:message key='dfk'/></c:when>
                                <c:when test="${item.status eq 2}"><fmt:message key='dfh1'/></c:when>
                                <c:when test="${item.status eq 3}"><fmt:message key='dsh1'/></c:when>
                                <c:when test="${item.status eq 4}"><fmt:message key='dpj'/></c:when>
                                <c:when test="${item.status eq 5}"><b style="color:green;"><fmt:message key='jywc'/></b></c:when>
                                <c:when test="${item.status eq 6}"><fmt:message key='yqx'/></c:when>
                            </c:choose>
                        </td>
                        <td>
                            <div class="layui-btn-container">
                                <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-xs feijin-detail"><fmt:message key='ck'/></a>
                            </div>
                        </td>
                    </tr>
                </c:forEach>
            </table>
            <jsp:include page="/commons/page.jsp" flush="true"/>
        </div>
    </div>

</div>

<script>

    $(function () {

        //查看详情
        $(".feijin-detail").click(function () {

            var id = $(this).attr("data-id");

            layer.open({
                type: 2
                , title: '<fmt:message key='ckxq'/>'
                , content: '${web_domain}/mall/order/' + id + '/detail'
                , maxmin: true
                , area: ['97%', '97%']
                , btn: ['<fmt:message key='fh'/>']
            });
        });

        //按时间排序
        $("#orderByCreateTime").click(function () {
            $(".feijin-orderby").attr("value", "");
            var orderBy = "${params.orderByCreateTime}";

            if (orderBy == "asc") {
                $("#orderByCreateTimeParams").attr("value", "");
                $("#search").click();
                return;
            }

            if (orderBy == "desc") {
                $("#orderByCreateTimeParams").attr("value", "asc");
                $("#search").click();
                return;
            }

            if (orderBy == "") {
                $("#orderByCreateTimeParams").attr("value", "desc");
                $("#search").click();
                return;
            }
        });

        //按余额排序
        $("#orderByPrice").click(function () {
            $(".feijin-orderby").attr("value", "");
            var orderBy = "${params.orderByPrice}";

            if (orderBy == "asc") {
                $("#orderByPriceParams").attr("value", "");
                $("#search").click();
                return;
            }

            if (orderBy == "desc") {
                $("#orderByPriceParams").attr("value", "asc");
                $("#search").click();
                return;
            }

            if (orderBy == "") {
                $("#orderByPriceParams").attr("value", "desc");
                $("#search").click();
                return;
            }

        });


    });
</script>
</body>
</fmt:bundle>
</html>